package com.jiyun.controller;


import com.jiyun.mapper.DriverMapper;
import com.jiyun.pojo.DcDriver;
import com.jiyun.service.DriverService;
import com.jiyun.utils.R;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/driver")
public class DriverController {

    @Autowired
    private DriverMapper driverMapper;
    @Autowired
    private DriverService driverService;

    @GetMapping("/findD")
    public List<DcDriver> findD() {
        return driverMapper.selectList(null);
    }

    @RequestMapping("findCarId")
    public Integer findCarId(Integer id) {
        return driverService.findCarId(id);
    }

    @GetMapping("/findOne")
    public DcDriver findOne(@RequestParam("tel") String tel) {
        DcDriver driver= driverService.findDriverByTel(tel);
        return driver;
    }

    @GetMapping("/tixian")
    public R tixian(String value1, Integer id){
        return driverService.tixin(value1,id);
    }

    @GetMapping("/sjById")
    public DcDriver sjById(Integer id){
        return driverService.sjById(id);
    }

    @PostMapping("/updateStatus")
    public void updateStatus(Integer id){
        driverService.updateStatus(id);
    }

    @PostMapping("/updateStatus2")
    public void updateStatus2(Integer id){
        driverService.updateStatus2(id);
    }

    @PostMapping("/cancelOrderCount")
    public void cancelOrderCount(Integer id) {
        driverService.cancelOrderCount(id);
    }
    @RequestMapping("findCount")
    public Integer findCount(Integer id) {
        return driverService.findCount(id);
    }

    @RequestMapping("updateDriverMoney")
    public void updateDriverMoney(Integer id){
        driverService.updateDriverMoney(id);
    }

    @RequestMapping("saveDriverMaoney")
    public void saveDriverMaoney(Integer id, BigDecimal totalAssets){
        driverService.saveDriverMaoney(id,totalAssets);
    }
}
